package com.tacuati.tests;

import org.json.JSONObject;

import com.tacuati.Utils;
import com.tacuati.content.Content;

public class Test1 {

	public static void main(String[] args) {
		try {
			Content content = new Content();
			String rootPath = "/media/Kindle";
			String pathCollectionsFile = rootPath + "/system/collections.json";
			String rootPathItems = rootPath + "/documents/";
			content.getContent(pathCollectionsFile, rootPathItems);
						
			JSONObject jsonFile1 = new JSONObject(Utils.readFileAsString(pathCollectionsFile));
			JSONObject jsonFile2 = new JSONObject(content.toJson());

			int diffs = 0;
			diffs += Utils.compareJsonObjects(jsonFile1, jsonFile2);
			diffs += Utils.compareJsonObjects(jsonFile2, jsonFile1);
			
			if (diffs==0){
				System.out.println("OK");
			} else {
				System.out.println("ERROR");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
